
package kayttoliittyma;

import java.util.ArrayList;
import java.util.Vector;
import java.util.logging.Level;
import java.util.logging.Logger;
import opintopaivakirja.*;

/**
 *
 * @author Erkkinuuttinen
 */
public class ProjektiJaMP extends javax.swing.JDialog {

    /**
     *
     * @param parent
     * @param modal
     * @param projektit
     * @param paikka
     */
    public ProjektiJaMP(javax.swing.JDialog parent, boolean modal, ArrayList<Projekti> projektit, int paikka) {
          super(parent, modal);
          initComponents();

          this.projektit = projektit;
          this.paikka = paikka;

          // asetetaan formiin tiedot
          this.asetaProjektinTiedot(projektit, paikka);

      }

    private void asetaProjektinTiedot(ArrayList<Projekti> projektit, int paikka){
        
        // valitaan taulukossa haluttu projekti
        Projekti projekti = projektit.get(paikka);
        // asetetaan tiedot
        jTextFieldNimi.setText(projekti.getNimi());
        jTextAreaKuvaus.setText(projekti.getEsittely());
        // TODO Projektin linkki on vallan unohtunut
        jTextFieldLinkki.setText("www.tut.fi/di-opinnot/");

        Vector<String> pnimet = new Vector<String>();
        for (Projekti p : projektit) {
            pnimet.add(p.getNimi());
        }

        jComboBoxProjektit.setModel(new javax.swing.DefaultComboBoxModel(pnimet));
        jComboBoxProjektit.updateUI();
    }

    /** This method is called from within the constructor to
     * initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is
     * always regenerated by the Form Editor.
     */
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jScrollPane1 = new javax.swing.JScrollPane();
        jPanel1 = new javax.swing.JPanel();
        merkki = new javax.swing.JLabel();
        otsikko = new javax.swing.JLabel();
        TiedotIkkuna = new javax.swing.JPanel();
        jLabel3 = new javax.swing.JLabel();
        jTextFieldNimi = new javax.swing.JTextField();
        jLabel4 = new javax.swing.JLabel();
        jComboBoxProjektit = new javax.swing.JComboBox();
        jLabel5 = new javax.swing.JLabel();
        jScrollPaneKuvaus = new javax.swing.JScrollPane();
        jTextAreaKuvaus = new javax.swing.JTextArea();
        jLabel6 = new javax.swing.JLabel();
        jTextFieldLinkki = new javax.swing.JTextField();
        jLabel7 = new javax.swing.JLabel();
        jLabel8 = new javax.swing.JLabel();
        jButton1 = new javax.swing.JButton();
        merkki1 = new javax.swing.JLabel();
        jLabel1 = new javax.swing.JLabel();
        jPanel2 = new javax.swing.JPanel();
        tavoite = new javax.swing.JTextField();
        MuistiinpanoCollapse = new javax.swing.JPanel();
        jScrollPane3 = new javax.swing.JScrollPane();
        jTextArea2 = new javax.swing.JTextArea();
        jLabel2 = new javax.swing.JLabel();
        jTextField3 = new javax.swing.JTextField();
        jLabel9 = new javax.swing.JLabel();
        jTextField4 = new javax.swing.JTextField();
        jLabel10 = new javax.swing.JLabel();
        jLabel11 = new javax.swing.JLabel();
        ArviointiCollapse = new javax.swing.JPanel();
        jScrollPane4 = new javax.swing.JScrollPane();
        jTextArea3 = new javax.swing.JTextArea();

        setDefaultCloseOperation(javax.swing.WindowConstants.DISPOSE_ON_CLOSE);

        jScrollPane1.setHorizontalScrollBarPolicy(javax.swing.ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);

        merkki.setText("▼");

        otsikko.setFont(new java.awt.Font("Tahoma", 1, 12));
        otsikko.setText("Projektin tiedot");
        otsikko.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                otsikkoMouseReleased(evt);
            }
        });

        TiedotIkkuna.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        jLabel3.setText("Projektin nimi:");

        jTextFieldNimi.addKeyListener(new java.awt.event.KeyAdapter() {
            public void keyTyped(java.awt.event.KeyEvent evt) {
                Painettu(evt);
            }
        });

        jLabel4.setText("Kuuluu:");

        jComboBoxProjektit.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Ohjelmistoprojekti", "Item 2", "Item 3", "Item 4" }));

        jLabel5.setText("Kuvaus:");

        jTextAreaKuvaus.setColumns(20);
        jTextAreaKuvaus.setRows(5);
        jScrollPaneKuvaus.setViewportView(jTextAreaKuvaus);

        jLabel6.setText("Linkki:");

        jTextFieldLinkki.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jTextFieldLinkkiActionPerformed(evt);
            }
        });

        jLabel7.setText("Aloitus pvm:");

        jLabel8.setText("Lopetus pvm:");

        jButton1.setText("Tallenna");
        jButton1.setToolTipText("Tallenna muutokset tietokantaan");
        jButton1.setEnabled(false);
        jButton1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                jButton1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout TiedotIkkunaLayout = new javax.swing.GroupLayout(TiedotIkkuna);
        TiedotIkkuna.setLayout(TiedotIkkunaLayout);
        TiedotIkkunaLayout.setHorizontalGroup(
            TiedotIkkunaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(TiedotIkkunaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(TiedotIkkunaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(TiedotIkkunaLayout.createSequentialGroup()
                        .addGroup(TiedotIkkunaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(TiedotIkkunaLayout.createSequentialGroup()
                                .addGroup(TiedotIkkunaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                                    .addComponent(jLabel3)
                                    .addComponent(jLabel5)
                                    .addComponent(jLabel6))
                                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                .addGroup(TiedotIkkunaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                    .addComponent(jTextFieldLinkki)
                                    .addGroup(TiedotIkkunaLayout.createSequentialGroup()
                                        .addComponent(jTextFieldNimi, javax.swing.GroupLayout.PREFERRED_SIZE, 167, javax.swing.GroupLayout.PREFERRED_SIZE)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                                        .addComponent(jLabel4)
                                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                                        .addComponent(jComboBoxProjektit, javax.swing.GroupLayout.PREFERRED_SIZE, 169, javax.swing.GroupLayout.PREFERRED_SIZE))
                                    .addComponent(jScrollPaneKuvaus)))
                            .addComponent(jLabel7))
                        .addContainerGap(199, Short.MAX_VALUE))
                    .addGroup(TiedotIkkunaLayout.createSequentialGroup()
                        .addComponent(jLabel8)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 273, Short.MAX_VALUE)
                        .addComponent(jButton1)
                        .addGap(245, 245, 245))))
        );
        TiedotIkkunaLayout.setVerticalGroup(
            TiedotIkkunaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(TiedotIkkunaLayout.createSequentialGroup()
                .addContainerGap()
                .addGroup(TiedotIkkunaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel3)
                    .addComponent(jTextFieldNimi, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(jLabel4)
                    .addComponent(jComboBoxProjektit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(TiedotIkkunaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel5)
                    .addComponent(jScrollPaneKuvaus, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(7, 7, 7)
                .addGroup(TiedotIkkunaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel6)
                    .addComponent(jTextFieldLinkki, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(TiedotIkkunaLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addGroup(TiedotIkkunaLayout.createSequentialGroup()
                        .addComponent(jLabel7)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                        .addComponent(jLabel8))
                    .addComponent(jButton1))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        merkki1.setText("▼");

        jLabel1.setFont(new java.awt.Font("Tahoma", 1, 12));
        jLabel1.setText("Projektin tavoitteet ja muistiinpanot");
        jLabel1.addMouseListener(new java.awt.event.MouseAdapter() {
            public void mouseReleased(java.awt.event.MouseEvent evt) {
                jLabel1MouseReleased(evt);
            }
        });

        jPanel2.setBorder(javax.swing.BorderFactory.createEtchedBorder());

        tavoite.setFont(new java.awt.Font("Tahoma", 2, 11));
        tavoite.setForeground(new java.awt.Color(153, 153, 153));
        tavoite.setText("Tavoite");

        jTextArea2.setColumns(20);
        jTextArea2.setFont(new java.awt.Font("Arial", 2, 12));
        jTextArea2.setForeground(new java.awt.Color(153, 153, 153));
        jTextArea2.setRows(5);
        jTextArea2.setText("Muistiinpano");
        jScrollPane3.setViewportView(jTextArea2);

        jLabel2.setText("Linkki:");

        jLabel9.setText("Tagi:");

        javax.swing.GroupLayout MuistiinpanoCollapseLayout = new javax.swing.GroupLayout(MuistiinpanoCollapse);
        MuistiinpanoCollapse.setLayout(MuistiinpanoCollapseLayout);
        MuistiinpanoCollapseLayout.setHorizontalGroup(
            MuistiinpanoCollapseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane3, javax.swing.GroupLayout.DEFAULT_SIZE, 484, Short.MAX_VALUE)
            .addGroup(MuistiinpanoCollapseLayout.createSequentialGroup()
                .addComponent(jLabel2)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jTextField3, javax.swing.GroupLayout.DEFAULT_SIZE, 451, Short.MAX_VALUE))
            .addGroup(MuistiinpanoCollapseLayout.createSequentialGroup()
                .addComponent(jLabel9)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(jTextField4, javax.swing.GroupLayout.DEFAULT_SIZE, 450, Short.MAX_VALUE))
        );
        MuistiinpanoCollapseLayout.setVerticalGroup(
            MuistiinpanoCollapseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(MuistiinpanoCollapseLayout.createSequentialGroup()
                .addComponent(jScrollPane3, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(MuistiinpanoCollapseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel2)
                    .addComponent(jTextField3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(MuistiinpanoCollapseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel9)
                    .addComponent(jTextField4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );

        jLabel10.setText("▼");

        jLabel11.setText("Arviointi");

        jTextArea3.setColumns(20);
        jTextArea3.setRows(5);
        jScrollPane4.setViewportView(jTextArea3);

        javax.swing.GroupLayout ArviointiCollapseLayout = new javax.swing.GroupLayout(ArviointiCollapse);
        ArviointiCollapse.setLayout(ArviointiCollapseLayout);
        ArviointiCollapseLayout.setHorizontalGroup(
            ArviointiCollapseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE)
        );
        ArviointiCollapseLayout.setVerticalGroup(
            ArviointiCollapseLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jScrollPane4, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
        );

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(tavoite, javax.swing.GroupLayout.PREFERRED_SIZE, 242, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGap(10, 10, 10)
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                            .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
                                .addGroup(jPanel2Layout.createSequentialGroup()
                                    .addComponent(jLabel10)
                                    .addGap(18, 18, 18)
                                    .addComponent(jLabel11))
                                .addComponent(ArviointiCollapse, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                            .addComponent(MuistiinpanoCollapse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))))
                .addContainerGap(162, Short.MAX_VALUE))
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(tavoite, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(MuistiinpanoCollapse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 49, Short.MAX_VALUE)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(jLabel10)
                    .addComponent(jLabel11))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addComponent(ArviointiCollapse, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
                    .addComponent(jPanel2, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addComponent(merkki)
                        .addGap(18, 18, 18)
                        .addComponent(otsikko))
                    .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
                        .addComponent(merkki1)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel1))
                    .addComponent(TiedotIkkuna, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
                .addContainerGap(390, Short.MAX_VALUE))
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(merkki)
                    .addComponent(otsikko))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(TiedotIkkuna, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
                .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(merkki1)
                    .addComponent(jLabel1))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(105, Short.MAX_VALUE))
        );

        jScrollPane1.setViewportView(jPanel1);

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
        getContentPane().setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 567, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
                .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 829, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );

        pack();
    }// </editor-fold>//GEN-END:initComponents

    private void otsikkoMouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_otsikkoMouseReleased
        if(TiedotIkkuna.isVisible()){
            TiedotIkkuna.setVisible(false);
            merkki.setText("►");
        } else {
            TiedotIkkuna.setVisible(true);
            merkki.setText("▼");
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_otsikkoMouseReleased

    private void jLabel1MouseReleased(java.awt.event.MouseEvent evt) {//GEN-FIRST:event_jLabel1MouseReleased
        if(jPanel2.isVisible()){
            jPanel2.setVisible(false);
            merkki1.setText("►");
        } else {
            jPanel2.setVisible(true);
            merkki1.setText("▼");
        }
        // TODO add your handling code here:
    }//GEN-LAST:event_jLabel1MouseReleased

    private void jTextFieldLinkkiActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jTextFieldLinkkiActionPerformed
        // TODO add your handling code here:
}//GEN-LAST:event_jTextFieldLinkkiActionPerformed

    private void jButton1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_jButton1ActionPerformed

        projektit.set(paikka, palautaKenttienArvotProjektiin());

        try {
            Kayttaja.class.newInstance().tallennaProjekti(projektit.get(paikka));
        } catch (InstantiationException ex) {
            Logger.getLogger(ProjektiJaMP.class.getName()).log(Level.SEVERE, null, ex);
        } catch (IllegalAccessException ex) {
            Logger.getLogger(ProjektiJaMP.class.getName()).log(Level.SEVERE, null, ex);
        }

        jButton1.setEnabled(false);

    }//GEN-LAST:event_jButton1ActionPerformed

    private Projekti palautaKenttienArvotProjektiin(){
        Projekti p = projektit.get(paikka);
        
        // nämä pitää tehdä niin että tarkistetaan mitä syötetään
        p.setNimi(jTextFieldNimi.getText());
        p.setEsittely(jTextAreaKuvaus.getText());

        return p;
    }
          
    private void Painettu(java.awt.event.KeyEvent evt) {//GEN-FIRST:event_Painettu
        System.out.println("Nappia painettu tekstikentässä");

        String vrt = projektit.get(paikka).getNimi();
        
        if(vrt.equals(jTextFieldNimi.getText())){
            jButton1.setEnabled(false);
        } else {
            jButton1.setEnabled(true);
        }
    }//GEN-LAST:event_Painettu

    /**
    * @param args the command line arguments
    */
//    public static void main(String args[]) {
//        java.awt.EventQueue.invokeLater(new Runnable() {
//            public void run() {
//                ProjektiJaMP dialog = new ProjektiJaMP(new javax.swing.JFrame(), true);
//                dialog.addWindowListener(new java.awt.event.WindowAdapter() {
//                    public void windowClosing(java.awt.event.WindowEvent e) {
//                        System.exit(0);
//                    }
//                });
//                dialog.setVisible(true);
//            }
//        });
//    }


    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JPanel ArviointiCollapse;
    private javax.swing.JPanel MuistiinpanoCollapse;
    private javax.swing.JPanel TiedotIkkuna;
    private javax.swing.JButton jButton1;
    private javax.swing.JComboBox jComboBoxProjektit;
    private javax.swing.JLabel jLabel1;
    private javax.swing.JLabel jLabel10;
    private javax.swing.JLabel jLabel11;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JLabel jLabel5;
    private javax.swing.JLabel jLabel6;
    private javax.swing.JLabel jLabel7;
    private javax.swing.JLabel jLabel8;
    private javax.swing.JLabel jLabel9;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JScrollPane jScrollPane1;
    private javax.swing.JScrollPane jScrollPane3;
    private javax.swing.JScrollPane jScrollPane4;
    private javax.swing.JScrollPane jScrollPaneKuvaus;
    private javax.swing.JTextArea jTextArea2;
    private javax.swing.JTextArea jTextArea3;
    private javax.swing.JTextArea jTextAreaKuvaus;
    private javax.swing.JTextField jTextField3;
    private javax.swing.JTextField jTextField4;
    private javax.swing.JTextField jTextFieldLinkki;
    private javax.swing.JTextField jTextFieldNimi;
    private javax.swing.JLabel merkki;
    private javax.swing.JLabel merkki1;
    private javax.swing.JLabel otsikko;
    private javax.swing.JTextField tavoite;
    // End of variables declaration//GEN-END:variables

    private ArrayList<Projekti> projektit;
    private int paikka;
}
